package com.freedy.dataStructure.hashTable;

import java.util.StringJoiner;

/**
 * @author Freedy
 * @date 2021/3/23 16:42
 */
public class Test {
    public static void main(String[] args) {
        HashTable<Integer, Emp> table = new HashTable<>(5);
        Emp emp1 = new Emp(1, "张三");
        Emp emp2 = new Emp(2, "王五");
        Emp emp3 = new Emp(3, "李四");
        Emp emp4 = new Emp(4, "王八蛋");
        table.put(1,emp1);
        table.put(2,emp2);
        table.put(3,emp3);
        table.put(1,emp4);
        System.out.println(table);
        table.printStructure();
        Emp s = table.get(7);
        System.out.println(s);
        table.remove(2);
        System.out.println(table);
        table.printStructure();
    }

     static class Emp{
        public int id;
        public String name;

        public Emp(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return new StringJoiner(", ", Emp.class.getSimpleName() + "[", "]")
                    .add("id=" + id)
                    .add("name='" + name + "'")
                    .toString();
        }
    }
}
